package br.unesp.demac.ccn07.aula6.stream;

import java.io.*;

public class CopiaBytes {

	/**
	 * @param args
	 */
	public static void copiaArquivo(String origem, String destino) {
		try {
			BufferedInputStream src = new BufferedInputStream(
					new FileInputStream(origem));
			BufferedOutputStream dest = new BufferedOutputStream(
					new FileOutputStream(destino));
			int disp;

			try {
				disp = src.available();
				byte dados[] = new byte[disp];
				src.read(dados, 0, disp);
				dest.write(dados, 0, disp);
				
				System.out.println(disp + " bytes copiados.");
				src.close();
				dest.flush();
				dest.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		copiaArquivo("C://Users//aluno//workspace2//test.txt", "C://Users//aluno//workspace2//test2.txt");
	}

}
